<%@ page import="br.com.qualityempresa.seguranca.Usuario"%>
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName" value="${message(code: 'usuario.label', default: 'Usuario')}" />
<title>
	Quality Empresa -
	<g:message code="default.list.label" args="[entityName]" />
</title>
</head>

<body screen_capture_injected="true">

	<ul class="nav nav-pills">
		<g:permissao devePossuir="true" controles="usuario" acoes="list">
			<li class="active">
				<g:link class="list" action="list">
					<i class="icon-list-alt"></i>
					<g:message code="default.list.label" args="[entityName]" />
				</g:link>
			</li>
		</g:permissao>
		<li class="divider-vertical"></li>
		<g:permissao devePossuir="true" controles="usuario" acoes="create">
			<li>
				<g:link action="create">
					<i class="icon-file"></i>
					<g:message code="default.add.label" args="[entityName]" />
				</g:link>
			</li>
		</g:permissao>
	</ul>

	<mensagem:renderizar mensagem="${flash}" />

	<g:form method="post" action="list">
		<legend>Pesquisar</legend>
		<div class="row">
			<div class="span8 control-group">
				<input class="span3" type="text" name="nome" value="${params?.nome}" placeholder="${message(code: 'usuario.nome.label')}" autofocus="autofocus">
				<input class="span2" type="email" name="email" value="${params?.email}" placeholder="${message(code: 'usuario.email.label')}">
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="submit" class="btn">
					<i class="icon-search"></i> Pesquisar
				</button>
				<g:link class="btn" action="limparBusca">
					<i class="icon-ban-circle"></i> Cancelar
				</g:link>
			</div>
		</div>
	</g:form>

	<h2>
		<g:message code="default.list.label" args="[entityName]" />
	</h2>
	<table class="table table-hover table-condensed table-striped table-blue">
		<thead>
			<tr>
				<th></th>
				<g:sortableColumn property="email" title="${message(code: 'usuario.email.label', default: 'Email')}" />
				<g:sortableColumn property="nome" title="${message(code: 'usuario.nome.label', default: 'Nome')}" />
				<g:sortableColumn property="perfil.nome" title="${message(code: 'usuario.perfil.label', default: 'Perfil')}" />
				<g:sortableColumn property="ativo" title="${message(code: 'usuario.ativo.label', default: 'Ativo')}" />
				<g:sortableColumn property="ultimoAcesso" title="${message(code: 'usuario.ultimoAcesso.label', default: 'Ultimo Acesso')}" />
			</tr>
		</thead>
		<tbody>
			<g:each in="${usuarioInstanceList}" status="i" var="usuarioInstance">
				<g:if test="${usuarioInstance.ativo == true}">
					<tr>
						<td>
							<g:link action="show" id="${usuarioInstance.id}">
								<i class="icon-eye-open"></i>
							</g:link>
						</td>
						<td>
							<g:link action="show" id="${usuarioInstance.id}">
								${fieldValue(bean: usuarioInstance, field: "email")}
							</g:link>
						</td>
						<td>
							${fieldValue(bean: usuarioInstance, field: "nome")}
						</td>
						<td>
							${fieldValue(bean: usuarioInstance, field: "perfil.nome")}
						</td>
						<td>				
							<g:formatBoolean boolean="${usuarioInstance.ativo}" />
						</td>
						<td>
							<g:formatDate date="${usuarioInstance.ultimoAcesso}" format="dd/MM/yyyy HH:mm" />
						</td>
					</tr>
				</g:if>
			</g:each>
		</tbody>
	</table>

	<div class="pagination">
		<g:paginate total="${usuarioInstanceTotal}" />
	</div>
</body>
</html>
